package areAlmostEqual;

import java.util.Arrays;

public class Solution {
    public boolean areAlmostEqual(String s1, String s2) {
        //
        char[] chars1 = s1.toCharArray();
        char[] chars2 = s2.toCharArray();
        int i = 0;
        int j = 1;
        while (i<s1.length()&&j<s2.length()) {
            if(chars1[i]==chars2[i]){
                i++;
                j = i+1;
            } else if (chars1[j]==chars2[j]) {
                j++;
            } else {
                char c = chars1[i];
                chars1[i] = chars1[j];
                chars1[j] = c;
                break;
            }
        }
        return Arrays.equals(chars1,chars2);
    }
}
